<?php
        $cekkunjunganiklan = mysql_query("SELECT * FROM kunjungandetiliklan WHERE id_iklan = '$link_id_iklan' AND tgl_kunjungan = curdate()");
        $jumlah = mysql_num_rows($cekkunjunganiklan);
        if($jumlah == 0)
        {
            $simpankunjungan = mysql_query("INSERT INTO kunjungandetiliklan(tgl_kunjungan, id_iklan, kunjungan_iklan) VALUES (curdate(),'$link_id_iklan','1')");
        }
        else
        {
            $updatekunjungan = mysql_query("UPDATE kunjungandetiliklan SET kunjungan_iklan = (kunjungan_iklan + '1') WHERE id_iklan = '$link_id_iklan' AND tgl_kunjungan = curdate()");
        }

        $query = mysql_query("SELECT * , (panjang*lebar) as luas FROM Iklan NATURAL JOIN anggota NATURAL JOIN kota_kabupaten NATURAL JOIN propinsi WHERE id_iklan = '$link_id_iklan'");
        $hasil1 = mysql_fetch_assoc($query);

?>


<div class="row">

            <div class="span9 main-wrap">

                <!-- Main Content -->
                <div class="main">

                    <section id="overview">

                        <div id="property-detail-flexslider" class="clearfix">
                            <div class="flexslider">


                                <ul class="slides">
                                    <li data-thumb="<?php echo $hasil1['foto_iklan']; ?>">
                                        <a href="<?php echo $hasil1['foto_iklan']; ?>" class="swipebox">
                                            <img src="<?php echo $hasil1['foto_iklan']; ?>" alt="image1">
                                        </a>
                                    </li>
                                    <li data-thumb="<?php echo $hasil1['foto_iklan2']; ?>">
                                        <a href="<?php echo $hasil1['foto_iklan2']; ?>" class="swipebox">
                                            <img src="<?php echo $hasil1['foto_iklan2']; ?>" alt="image2">
                                        </a>
                                    </li>
                                    <li data-thumb="<?php echo $hasil1['foto_iklan3']; ?>">
                                        <a href="<?php echo $hasil1['foto_iklan3']; ?>" class="swipebox">
                                            <img src="<?php echo $hasil1['foto_iklan3']; ?>" alt="image3">
                                        </a>
                                    </li>
                                    <li data-thumb="<?php echo $hasil1['foto_iklan4']; ?>">
                                        <a href="<?php echo $hasil1['foto_iklan4']; ?>" class="swipebox">
                                            <img src="<?php echo $hasil1['foto_iklan4']; ?>" alt="image4">
                                        </a>
                                    </li>
                                </ul>


                            </div>
                        </div>

                        <article class="property-item clearfix">

                            <div class="wrap clearfix">
                                <h4 class="title"> <?php echo $hasil1['judul_iklan'] ?>/ <?php echo $hasil1['kota_kabupaten'] ?>, <?php echo $hasil1['propinsi'] ?> </h4>
                                <h5 class="price">
                                    <span class="status-label">
                                        <?php echo $hasil1['jenis']; ?>
                                    </span>
                                    <span>
                                        <?php echo "Rp. "; echo $hasil1['harga']; ?> <small> <?php echo "-"; echo $hasil1['jenis_pembayaran']; ?></small>
                                    </span>
                                </h5>
                            </div>

                            <div class="property-meta clearfix">
                                <span><i class="icon-area"></i><?php echo $hasil1['luas']; ?> M<sup>2&nbsp;</span><span><i class="icon-bed"></i><?php echo $hasil1['banyak_kamar']; ?>&nbsp;Kamar Tidur</span><span><i class="icon-bath"></i><?php echo $hasil1['banyak_kamarmandi']; ?>&nbsp;Kamar Mandi</span><span><i class="icon-garage"></i><?php echo $hasil1['fasilitas3'];  ?></span>
                                <!-- Print Icon -->
                                <span class="printer-icon"><a href="javascript:window.print()">Print this page</a></span>
                            </div>

                            <div class="content clearfix">
                                <b>Alamat   :</b>
                                    <br>
                                    <?php echo $hasil1['alamat']; ?>
                                    <br><br><br>
                                <b>Deskripsi    :</b><br>
                                <?php echo $hasil1['keterangan']; ?>
                            </div>

                            <div class="features">
                                <h4 class="title">Features</h4>
                                <ul class="arrow-bullet-list clearfix">
                                    <?php

                                        if($hasil1['fasilitas1'] == 'Internet')
                                        {
                                            echo "<li><a> Internet </a></li>";
                                        }
                                        else
                                        {
                                            echo "";
                                        }
                                        if($hasil1['fasilitas2'] == 'Tempat Tidur')
                                        {
                                            echo "<li><a> Tempat Tidur </a></li>";
                                        }
                                        else
                                        {
                                            echo "";
                                        }
                                        if($hasil1['fasilitas3'] == 'Garasi')
                                        {
                                            echo "<li><a> Garasi </a></li>";
                                        }
                                        else
                                        {
                                            echo "";
                                        }
                                        if($hasil1['fasilitas3'] == 'AC')
                                        {
                                            echo "<li><a> Pendingin Ruangan </a></li>";
                                        }
                                        else
                                        {
                                            echo "";
                                        }

                                    ?>
                                </ul>
                            </div>

                        </article>


                        <div class="map-wrap clearfix">
                            
                            <div class="share-networks clearfix">
                                <span class="share-label">Bagikan iklan ini</span>
                                <span><a target="_blank" href="https://www.facebook.com/"><i class="icon-facebook"></i>Facebook</a></span>
                                <span><a target="_blank" href="https://twitter.com/"><i class="icon-twitter"></i>Twitter</a></span>
                                <span><a target="_blank" href="https://plus.google.com/"><i class="icon-google-plus"></i>Google</a></span>
                            </div>
                        </div>

                        <div class="agent-detail clearfix">

                            <div class="left-box">
                                <h3><?php echo $hasil1['nama_anggota'] ?></h3>
                                <figure>
                                    <a href="#">
                                        <img src="<?php echo $hasil1['foto_profile'] ?>"  alt="agent pic">
                                    </a>
                                </figure>
                                
                                <ul class="contacts-list">
                                    <!-- <li class="office">Office : 041-456-7890</li> -->
                                    <li class="mobile">Kontak : <?php echo $hasil1['kontak'] ?></li>
                                    <!-- <li class="fax">Fax  : 041-789-1234</li> -->
                                </ul>
                            </div>

                            <div class="contact-form">

                                <h3>Contact</h3>

                                <form id="agent-contact-form" class="contact-form-small" method="post" action="http://inspirythemes.com/templates/realhomes-html/agent_form_handler.php">

                                    <input type="text" name="nama" id="nama" value="Nama" class="required" title="* Ketikan nama anda">

                                    <input type="text" name="email" id="email" value="Email" class="email required" title="* Ketikan alamat email anda">

                                    <textarea name="pesan" id="comment" class="required" title="* Silahkan ketikan pesan anda">Pesan</textarea>

                                    <input type="hidden" name="target" value="<?php echo $hasil1['email'] ?>">
                                    <input type="hidden" name="action" value="send_message_to_agent">
                                    <input type="hidden" name="property_title" value="<?php echo $hasil1['judul_iklan'] ?>">
                                    <input type="hidden" name="property_permalink" value="">

                                    <input type="submit" value="Submit" name="submit" class="real-btn">
                                    <img src="images/ajax-loader.gif" id="contact-loader" alt="Loading...">

                                </form>

                                <div class="error-container"></div>
                                <div id="message-sent">&nbsp;</div>
                            </div>
                        </div>


                    </section>

                </div><!-- End Main Content -->

            </div> <!-- End span9 -->

            <div class="span3 sidebar-wrap">

                <!-- Sidebar -->
                <aside class="sidebar">
                    <section class="widget"
                            ><h3 class="title">Iklan Terkait</h3>
                        <ul class="featured-properties">
                            
                            <?php
                                $email = $hasil1['email'];
                                $query1 = mysql_query("SELECT * FROM iklan WHERE email = '$email' ");
                               while ($hasil2 = mysql_fetch_array($query1))
                               {
                                include "iklanterkait.php";
                                }
                            ?>

                        </ul>
                    </section>    </aside><!-- End Sidebar -->

            </div>

        </div><!-- End contents row -->
